package com.dragonh.service;

import com.dragonh.exception.CssException;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;

/**
 * Description:
 * ========================================================================
 * <p>
 * ------------------------------------------------------------------------
 *
 * @author allen
 * date                2025/1/25
 * @since 1.0.0
 * <p>
 * ========================================================================
 */
public interface CloudStorageService {
    String upload(InputStream inputStream, String cloudPath);

    default String upload(byte[] data, String cloudPath) {
        return upload(new ByteArrayInputStream(data), cloudPath);
    }

    default String upload(String localPath, String cloudPath) {
        try {
            return upload(Files.newInputStream(Paths.get(localPath)), cloudPath);
        } catch (Exception e) {
            throw new CssException(e);
        }
    }

    boolean delete(String cloudPath);


    InputStream download(String cloudPath);

    File downloadAsFile(String cloudPath,String localPath);
}
